package test00.test05.t01.demo01;

import test00.test05.t01.Student;

import java.util.Arrays;
import java.util.function.Supplier;

/**
 * @Author lzp
 * @Date 2024-04-11
 */
public class SupplierImpl implements Supplier<Student> {

    private Student[] students;

    public SupplierImpl(Student[] students) {
        this.students = students;
    }


    @Override
    public Student get() {
        Arrays.sort(students, (stu1, stu2) -> stu2.getAge() - stu1.getAge());
        return students[students.length-1];
    }
}
